package com.ky.home.mapper;

import com.ky.home.entity.Checkins;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.ky.home.entity.VO.CheckinVO;
import org.apache.ibatis.annotations.Mapper;

import org.apache.ibatis.annotations.Select;



/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author pl
 * @since 2024-06-18
 */
@Mapper
public interface CheckinsMapper extends BaseMapper<Checkins> {
    @Select("SELECT MAX(id) FROM checkins")
    int selectMaxId();
    @Select("SELECT COUNT(*) FROM checkins WHERE DATE(add_at) = CURRENT_DATE()")
    int countTodayCheckin();
    @Select("SELECT c.*, u.* FROM checkins c LEFT JOIN user u ON c.user_id = u.id WHERE c.id = #{id}")
    CheckinVO findCheckinsByUserId(int id);
}
